package com.example.mobile2121606110syc0409homework;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity5 extends AppCompatActivity {

    private TextView tvMainTitle5;
    private TextView tvMainTit51;
    private TextView tvMainTit53;
    private ImageView imgMainhs;
    private TextView tvMainTit54;
    private EditText edtTtMain5;
    private Button btnMain5;
    private TextView tvMainTit55;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main5);
        initView();
        btnMain5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int x = Integer.parseInt(edtTtMain5.getText().toString());
                if(x < 1){
                    tvMainTit55.setText(String.valueOf(x));
                }else if (1 <= x && x <10){
                    x = 2 * x - 1;
                    tvMainTit55.setText(String.valueOf(x));
                }else if (x >= 10) {
                    x = 3 * x - 11;
                    tvMainTit55.setText(String.valueOf(x));
                }
            }
        });
    }

    private void initView() {
        tvMainTitle5 = (TextView) findViewById(R.id.tvMainTitle5);
        tvMainTit51 = (TextView) findViewById(R.id.tvMainTit51);
        tvMainTit53 = (TextView) findViewById(R.id.tvMainTit53);
        imgMainhs = (ImageView) findViewById(R.id.imgMainhs);
        tvMainTit54 = (TextView) findViewById(R.id.tvMainTit54);
        edtTtMain5 = (EditText) findViewById(R.id.edtTtMain5);
        btnMain5 = (Button) findViewById(R.id.btnMain5);
        tvMainTit55 = (TextView) findViewById(R.id.tvMainTit55);
    }
}